<template>
  <div class="hello">
    <h1>{{ text }}</h1>
    <button @click="clearText" style="margin-top: 10px; padding: 5px 10px;">清空</button>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    text: {
      type: String,
      default: ''
    }
  },
  methods: {
    clearText() {
      this.$emit('clear') // 通知父组件清空
    }
  }
}
</script>

<style scoped>
h1 {
  font-size: 24px;
  margin-bottom: 10px;
}
</style>
